package com.yohann.statistics.controller;


import com.yohann.commonutils.result.R;
import com.yohann.statistics.entity.Daily;
import com.yohann.statistics.service.DailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author Yohann
 * @since 2020-09-02
 */
@RestController
@RequestMapping("/service_statistics/statistics-daily")
public class DailyController {
    @Autowired
    private DailyService dailyService;

    /**
     * 统计一天注册人数
     * @param day
     * @return
     */
    @GetMapping("registerCount/{day}")
    public R registerCount(@PathVariable String day){
        dailyService.registerCount(day);
        return R.ok();
    }

    /**
     * 查询数据
     * @param type
     * @param begin
     * @param end
     * @return
     */
    @GetMapping("showData/{type}/{begin}/{end}")
    public R showData(@PathVariable String type,@PathVariable String begin,@PathVariable String end){
        Map<String,Object> map = dailyService.showData(type,begin,end);
        return R.ok().data(map);
    }
}

